package com.twu.stub;

import java.io.OutputStream;
import java.io.PipedOutputStream;
import java.io.PrintStream;

/**
 * Created with IntelliJ IDEA.
 * User: root
 * Date: 6/28/13
 * Time: 1:41 AM
 * To change this template use File | Settings | File Templates.
 */
public class StubOutputStream extends PrintStream {
    private StringBuffer sb = new StringBuffer();

    public StubOutputStream(OutputStream out) {
        super(out);
    }

    public static StubOutputStream createStubOutputStream(){
        return new StubOutputStream(new PipedOutputStream());
    }

    public void print(String s){
        sb.append(s);
    }

    public void println(String s){
        sb.append(s);
    }

    public String result(){
        return sb.toString();
    }
}

